package com.ibm.util;

import java.util.List;
import java.util.regex.Pattern;

public class StringUtil {
	private StringUtil(){}
	
	public static boolean isDigit(String input) {
		if (input == null) {
			return false;
		}
		Pattern pattern = Pattern.compile("-?\\+?[0-9]+");
		return pattern.matcher(input).matches();
	}
	
	public static String removeQuotes(String str){
		if (str.charAt(0) == '\"' && str.charAt(str.length() - 1) == '\"') {
			return str.substring(1, str.length() - 1);
		}
		return str;
	}
	
	public static String join(List<?> objs, String splitter){
		StringBuilder builder = new StringBuilder();
		if(objs == null || objs.isEmpty())
			return builder.toString();
		builder.append(objs.get(0));
		for (int i = 0; i < objs.size(); i++) {
			builder.append(splitter);
			builder.append(objs.get(i));
		}
		return builder.toString();
	}
}
